<?php
if (! defined ( 'BASEPATH' )) exit ( 'No direct script access allowed' );
/**
 * short message service
 *
 * @author fan
 *
 */
class Sms {
	public function __construct() {

		$this->CI = & get_instance ();
	}
	
	/**
	 * [发送短信]
	 * @author fans
	 * @date 2016-7-20
	 **/
	public function send( $mobile , $content )
	{
		$code = time().rand(1000,9999);
		$content = UrlEncode(base64_encode(iconv("UTF-8","GBK",$content)));
		$url =SEND_URL.'?userId='.SEND_NAME.'&password='.SEND_PASS.'&multixmt='.$code.'|*|'.$mobile.'|'.$content;
        $this->CI->logs->smsmass($url.' 状态码：'."\n \r");//记录日志;
		$result = sendHttp($url,'','get');
		return $this->errcode($result['str']);
	}

	/**
	 * [错误提示码]
	 * @param  [type] $code [description]
	 */
	public function errcode($code){
		$arr = array('-1','-12','-999','-2','-10','-11','-12','-13','-14','-101','-102','-103','-200','-999','-10001','-10003','-10011','-10029','-10030','-10031','-10057','-10056');
		if(in_array($code,$arr)){
			return false;
		}
		return true;
	}
}
